#ifndef CVIDEOCAPTRUE_H
#define CVIDEOCAPTRUE_H

#include <QThread>
#include <vector>
#include <QVector>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "face_detection.h"
using namespace cv;
using namespace std;

Q_DECLARE_METATYPE(cv::Mat)
class CVideocaptrue : public QThread
{
    Q_OBJECT
public:
    CVideocaptrue(QObject* parent = 0);
    ~CVideocaptrue();
    void UserReg(QString strNo, QString strName);
    void StartFaceCheck();
    int OneFaceDetect(cv::Mat& newImgMat);
    bool SaveJpg(Mat& matImg, QString strFileName);

protected:
    void run();

signals:
    void sigRegister(QString strId, QString strName, QByteArray imgs);
    void sigRegReturn(QString strId, QString strName, QString imgs);
    void sigRequestFaceCheck(QVector<Mat> vMatFace);

public slots:
    void slotFaceDectReturn(QString strId, QVector<int> vResult, bool bResult);

private slots:
    void slotRegister(QString strId, QString strName, QByteArray imgs);
    void slotRequestFaceCheck(QVector<Mat> vMatFace);

private:
    bool m_bStop;
    bool m_bRegister;
    bool m_bStartCheck;
    QString m_strNo;
    QString m_strName;
    QVector<Mat> m_vMatFaceCheck;
    CascadeClassifier m_cascade; //opencv classifier
    seeta::FaceDetection* detector;
};

#endif // CVIDEOCAPTRUE_H
